
<?php
    $url = new Url();
    $arr_region = LoadConfig::$region;

    //var_dump($arr_region);
?>

<script type="text/javascript">

    loadBoxSearch();
    
    $(document).ready(function(){
       
       loadChat("<?=$url->createUrl('home/chat')?>");
            
        $('.From').keypress(function(e){
            if(e.keyCode == 13 && !e.shiftKey){
                $(this).trigger("enterKey");
            } 
        });

        $('textarea').bind("enterKey",function(e){
            var messenger = $('.From').val();
            var url = "<?=$url->createUrl('home/chat'); ?>";
            $.ajax({
                type: "GET",
                url: url,
                global: false,
                data: {
                    messenger: messenger,
                },
                success: function(msg){  
                    if(msg==1){
                        alert('Bạn phải đăng nhập để tán gẫu');
                    }
                    if(msg==0){
                        alert('Bạn phải chưa nhập nội dung');
                    }
                    else
                    {
                        $("#CHAT").html(msg);
                        $('.From').val('');
                    }

                }
            });
        });
        
    });
    
    function messenger(){
        var messenger = $('.From').val();
        var url = "<?=$url->createUrl('home/chat'); ?>";
        $.ajax({
            type: "GET",
            url: url,
            global: false,
            data: {
                messenger: messenger,
            },
            success: function(msg){
                if(msg==1){
                    alert('Bạn phải đăng nhập để tán gẫu');
                }
                if(msg==0){
                    alert('Bạn phải chưa nhập nội dung');
                }
                else
                {
                    $("#CHAT").html(msg);
                    $('.From').val('');
                } 
            }
        });
    };

    function loadChat(url){
        var scroll = $('.boxCHAT').scrollTop();
        //alert(scroll);
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                
            },
            success:function(msg){
                $("#CHAT").html(msg);
            }
        });
    }
    
    function loadBoxSearch(){
        var url = "<?=$url->createUrl('home/boxsearch');?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{},
            success: function(msg){
                $("#boxsearch").html(msg);
            }
        });
    }

</script>


<div class="leftMain">
    <div class="menuXS">
        <ul>
            <li id="mienbac"><a href="<?php echo Yii::app()->createUrl('ketqua/mienbac')?>">XỔ SỐ MIỀN BẮC</a></li>
            <li id="mientrung"><a href="<?php echo Yii::app()->createUrl('ketqua/mientrung')?>">XỔ SỐ MIỀN TRUNG</a></li>
            <li id="miennam"><a href="<?php echo Yii::app()->createUrl('ketqua/miennam')?>">XỔ SỐ MIỀN NAM</a></li>
            <li id="dientoan"><a href="<?php echo Yii::app()->createUrl('ketqua/dientoan')?>">XỔ SỐ ĐIỆN TOÁN</a></li>
        </ul>
    </div>

    <div class="Calendar">
        <div>
            <a href="javascript:void(0);">
                <h1><input type="text" class="boxCalendar" value="Xổ số <?php echo $tinh['name']?>" readonly style="text-align: center; width: 400px"></h1>
            </a>
        </div>

        <div class="arrowCalendar_1">
            <a href="<?php echo Yii::app()->createUrl('ketqua/timmientrung',array('last'=>$data['ngay_quay'],'id'=>$id,'alias'=>$alias));?>"><img src="<?php echo Yii::app()->params['static_url'];?>images/xo-so-10h-icon-arrowlich.png" style="padding-top:14px;"/></a>
        </div>
        <div class="arrowCalendar_2">
            <a href="<?php echo Yii::app()->createUrl('ketqua/timmientrung',array('next'=>$data['ngay_quay'],'id'=>$id,'alias'=>$alias));?>"><img src="<?php echo Yii::app()->params['static_url'];?>images/xo-so-10h-icon-arrowlich2.png" style="padding-top:14px;"/></a>
        </div>
    </div>

    <div class="XSMB">
        <div class="leftXSMB  m-b-20">
            <div class="titleXSMB">
                Kết quả sổ xố trực tiếp tỉnh <?php echo $tinh['name']; ?> ngày <span class="red"><?php echo date('d/m/Y',strtotime($data['ngay_quay'])); ?></span>
            </div>
            <div class="tableXSMB">
                <ul>
                    <li>
                        <div class="giaiXSMB">
                            <p class="red">Giải đặc biệt</p>
                        </div>
                        <div class="kqXSMB">
                            <p class="font24 red"><?php echo $data['giai_dacbiet']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải nhất</p>
                        </div>
                        <div class="kqXSMB bg_kqXSMB">
                            <p class="font18 "><?php echo $data['giai_nhat']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải nhì</p>
                        </div>
                        <div class="kqXSMB">
                            <p class="font18 "><?php echo $data['giai_nhi']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải ba</p>
                        </div>
                        <div class="kqXSMB bg_kqXSMB">
                            <p class="font18 "><?php echo $data['giai_ba_1']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_ba_2']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải tư</p>
                        </div>
                        <div class="kqXSMB">
                            <p class="font18 "><?php echo $data['giai_tu_1']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_tu_2']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_tu_3']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_tu_4']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_tu_5']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_tu_6']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_tu_7']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải năm</p>
                        </div>
                        <div class="kqXSMB bg_kqXSMB">
                            <p class="font18 "><?php echo $data['giai_nam']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải sáu</p>
                        </div>
                        <div class="kqXSMB">
                            <p class="font18 "><?php echo $data['giai_sau_1']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_sau_2']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['giai_sau_3']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải bảy</p>
                        </div>
                        <div class="kqXSMB bg_kqXSMB">
                            <p class="font18 "><?php echo $data['giai_bay']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải tám</p>
                        </div>
                        <div class="kqXSMB bg_kqXSMB">
                            <p class="font18 "><?php echo $data['giai_tam']; ?></p>
                        </div>
                        <div class="both"></div>
                    </li>
                </ul>
            </div> 
        </div>

        <?php
            $arr_data[1]= $data['giai_dacbiet'];
            $arr_data[2]= $data['giai_nhat'];
            $arr_data[3]= $data['giai_nhi'];
            $arr_data[4]= $data['giai_ba_1'];
            $arr_data[5]= $data['giai_ba_2'];
            $arr_data[6]= $data['giai_tu_1'];
            $arr_data[7]= $data['giai_tu_2'];
            $arr_data[8]= $data['giai_tu_3'];
            $arr_data[9]= $data['giai_tu_4'];
            $arr_data[10]= $data['giai_tu_5'];
            $arr_data[11]= $data['giai_tu_6'];
            $arr_data[12]= $data['giai_tu_7'];
            $arr_data[13]= $data['giai_nam'];
            $arr_data[14]= $data['giai_sau_1'];
            $arr_data[15]= $data['giai_sau_2'];
            $arr_data[16]= $data['giai_sau_3'];
            $arr_data[17]= $data['giai_bay'];
            $arr_data[18]= $data['giai_tam'];
            //var_dump($arr_data);
        ?>

        <div class="rightXSMB_2">
            <ul>
                <li>
                    <div class="Dau_LOTO">
                        Đầu
                    </div>
                    <div class="Duoi_LOTO">
                        <p>Cuối</p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>0</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==0)
                                    {
                                        echo substr($arr_data[$j],-1,1)." ";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>1</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==1)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>2</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p> 
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==2)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>3</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php  
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==3)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }                       
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>4</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p> 
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==4)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>5</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==5)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }  
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>6</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==6)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>7</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==7)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>8</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==8)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
                <li>
                    <div class="Dau_LOTO">
                        <p>9</p>
                    </div>
                    <div class="Duoi_LOTO">
                        <p>
                            &nbsp;
                            <?php
                                for($j=1;$j<=count($arr_data);$j++)
                                {
                                    if(substr($arr_data[$j],-2,1)==9)
                                    {
                                        echo substr($arr_data[$j],-1,1)."&nbsp;";
                                    }
                                }
                            ?>
                        </p>
                    </div>
                    <div class="both"></div>
                </li>
            </ul>
        </div>
        <div class="both"></div>
    </div>

    <div class="MXH">
        <div id="fb-root" style="float: right;"></div>
        <script>(function(d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id)) return;
                js = d.createElement(s); js.id = id;
                js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=670383849682676&version=v2.0";
                fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));
        </script>
        <div class="fb-like" data-href="http://10h.vn/" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>
    </div>

    <div class="CHAT">
            
        <div class="titleCHAT">
            Tán Gẫu
        </div>
        
        <div class="CHATarea">
            <textarea name="CHAT" placeholder="Nhập nội dung chat" cols="50" rows="1" class="From"></textarea>
        </div>
        <div style="padding:15px 20px 20px 0; text-align:right;">
            <a href="javascript:void(0);" id="emotion"><img src="<?php echo Yii::app()->params['static_url'];?>images/xo-so-10h-icon-yahoo.png" width="22" height="22" style="padding-right:10px;"></a>
            <a href="javascript:void(0);" onclick="loadChat('<?=$url->createUrl('home/chat')?>');"><img src="<?php echo Yii::app()->params['static_url'];?>images/Refresh.png" width="22" height="22" style="padding-right:10px;" /></a>
            <input type="button" onclick="messenger();" class="button_KQ" value="Gửi">
        </div>

        <div class="boxCHAT" id="CHAT"></div>
        
        <?php $this->renderPartial('boxemotion');?>
        
    </div>


</div>

<div class="rightMain">

    <div class="Box" id="boxsearch"></div>

    <div class="Box" id="boxtienich">
        <?php $this->renderPartial('boxtienich');?>
    </div>

    <div class="Box" id="boxthongke">
        <?php $this->renderPartial('boxthongke');?>
    </div>

</div>
        <div class="both"></div>